package com.atguigu.spzx.manager.controller;

import com.atguigu.spzx.manager.service.FileService;
import com.atguigu.spzx.model.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * title:
 * author: zgl
 * date: 2023/12/29
 * description：
 */
@RestController
@RequestMapping("/admin/system/file")
@Tag(name = "文件管理模块")
public class FileController {
    @Autowired
    private FileService fileService;

    //文件上传
    @PostMapping("/upload/{module}")
    @Operation(summary = "文件上传接口")
    public Result upload(@PathVariable String module, MultipartFile file) {
        String filePath = fileService.upload(module, file);
        return Result.ok(filePath);
    }

    //删除文件上传
    @DeleteMapping("/deleteFile")
    @Operation(summary = "删除文件上传接口")
    public Result deleteFile(String path){
        fileService.delete(path);
        return Result.ok();
    }
}
